package com.study;

import com.study.service.UserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Consumer {
    public static void main(String[] args) throws IOException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consumer.xml");
        context.start();
        System.out.println("dubbo服务消费端已启动...");
        UserService userService = (UserService) context.getBean(UserService.class);// 获取远程服务代理
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        do {
            // 从控制台读取一行数据，返回值字符串
            str = br.readLine();
            System.out.println(str);
            String hello = userService.get(2);//执行远程方法
            System.out.println(hello);//显示调用结果
        } while (!str.equals("exit"));

    }
}
